Skip to content

Conversation

@sagnghos
Copy link
Contributor

Add support for connection to experimental host using the go-sql-spanner driver

The driver should be able to connect to a Spanner experimental host endpoint using:

  • plain text
  • tls
  • mTLS

The integration tests have been modified to test the above scenarios against experimental host setup

  • plain text
go test -v . -args -it.experimental-host="localhost:15000"
  • tls
go test -v . -args -it.experimental-host="localhost:15000" -it.ca-cert-file="/tmp/experimental_host/ca-certificates/ca.crt"
  • mTLS
go test -v . -args -it.experimental-host="localhost:15000" -it.ca-cert-file="/tmp/experimental_host/ca-certificates/ca.crt" -it.client-cert-file="/tmp/experimental_host/certs/client.crt" -it.client-cert-key="/tmp/experimental_host/certs/client.key"

@sagnghos sagnghos requested a review from a team as a code owner January 14, 2026 06:09
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sagnghos, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the go-sql-spanner driver by introducing comprehensive support for connecting to experimental Spanner host environments. This change allows developers to configure secure connections using various TLS modes, including mutual TLS, and provides a dedicated DSN format for these specialized endpoints. The modifications ensure that the driver can seamlessly interact with experimental setups, which is crucial for development and testing workflows, without impacting the standard production connection mechanisms.

Highlights

  • Experimental Host Support: The driver now supports connecting to experimental Spanner host endpoints, enabling testing and development against non-production environments.
  • Flexible Connection Security: Connections to experimental hosts can be established using plain text, TLS (Transport Layer Security), or mTLS (mutual TLS) for enhanced security options.
  • New DSN Format for Experimental Hosts: A new DSN (Data Source Name) format, starting with spanner://, has been introduced for experimental host connections, allowing for explicit configuration of host, database, and security parameters.
  • Certificate-Based Authentication: New connection properties (ca_cert_file, client_cert_file, client_cert_key) have been added to specify certificate paths for TLS and mTLS connections.
  • Integration Test Coverage: The integration test suite has been updated to include scenarios for connecting to experimental hosts using plain text, TLS, and mTLS, ensuring robust functionality.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for connecting to an experimental Spanner host, including plaintext, TLS, and mTLS connections. The changes are well-structured and include corresponding integration tests. I've identified a couple of areas for improvement, mainly around improving the robustness of the mTLS configuration and reducing code duplication in the integration tests. Overall, this is a solid contribution.

// - rpcPriority: Sets the priority for all RPC invocations from this connection (HIGH/MEDIUM/LOW). The default is HIGH.
//
// Example: `localhost:9010/projects/test-project/instances/test-instance/databases/test-database;usePlainText=true;disableRouteToLeader=true;enableEndToEndTracing=true`
var dsnRegExp = regexp.MustCompile(`((?P<HOSTGROUP>[\w.-]+(?:\.[\w\.-]+)*[\w\-\._~:/?#\[\]@!\$&'\(\)\*\+,;=.]+)/)?projects/(?P<PROJECTGROUP>(([a-z]|[-.:]|[0-9])+|(DEFAULT_PROJECT_ID)))(/instances/(?P<INSTANCEGROUP>([a-z]|[-]|[0-9])+)(/databases/(?P<DATABASEGROUP>([a-z]|[-]|[_]|[0-9])+))?)?(([\?|;])(?P<PARAMSGROUP>.*))?`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python wrapper tests are failing, and I think that is related to the changes here. It seems like there are some changes to HOSTGROUP. Are those intentional?

Also, the regex now has a ^ and $, which would (probably) disallow leading/trailing spaces, which could be the reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the change to HOSTGROUP was intentional. Otherwise it was capturing /databases in the host group itself after projects and instances were made optional

As for the error you are kind of correct. I think the spannerlib-python is buggy. The setup was generating the url as localhost:9010projects/test-project/.... But since the ^ and $ was not there the absence of "/" between localhost:9010 and projects didn't raise a error. Now its catching it. I have made the change in the test setup itself. Let me know if you have other suggestions.

@olavloite olavloite requested a review from bhatt4982 January 16, 2026 14:17
Copy link
Contributor

@bhatt4982 bhatt4982 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM...

@olavloite olavloite merged commit 36908a2 into googleapis:main Jan 16, 2026
39 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants